/*
 * 版权所有 (c) 华为技术有限公司 2022-2022
 */
package com.huawei.cameratest.data;

import android.hardware.camera2.CaptureResult;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class CaptureResultEx {
    public static CaptureResult.Key AIRESPONSE = instance("com.camera.capture.metadata.aiResponse", int[].class);
    public static CaptureResult.Key AI_DATA = instance("com.camera.capture.metadata.skeletonDetectionData", Byte[].class);
    public static CaptureResult.Key TIMESTAMP = instance("com.camera.capture.metadata.rokitTimestamp", int.class);
    public static CaptureResult.Key ISPUPDATE_STATUS = instance("com.camera.capture.metadata.ispUpdateStatus", int[].class);
    public static CaptureResult.Key ODM_META = instance("com.camera.capture.metadata.odmMeta", byte[].class);

    private static CaptureResult.Key instance(String tag, Class cla) {
        try {
            Class classes = Class.forName("android.hardware.camera2.CaptureResult$Key");
            Constructor constructor = classes.getConstructor(String.class, Class.class);
            CaptureResult.Key key = (CaptureResult.Key) constructor.newInstance(tag, cla);
            return key;
        } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}